package pt.nmfa.peste.session;

import pt.nmfa.peste.entity.*;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityHome;

@Name("channelTypeHome")
public class ChannelTypeHome extends EntityHome<ChannelType> {

	public void setChannelTypeId(ChannelTypeId id) {
		setId(id);
	}

	public ChannelTypeId getChannelTypeId() {
		return (ChannelTypeId) getId();
	}

	public ChannelTypeHome() {
		setChannelTypeId(new ChannelTypeId());
	}

	@Override
	public boolean isIdDefined() {
		if (getChannelTypeId().getEpgPos() == null
				|| "".equals(getChannelTypeId().getEpgPos()))
			return false;
		if (getChannelTypeId().getCategory() == null
				|| "".equals(getChannelTypeId().getCategory()))
			return false;
		return true;
	}

	@Override
	protected ChannelType createInstance() {
		ChannelType channelType = new ChannelType();
		channelType.setId(new ChannelTypeId());
		return channelType;
	}

	public void load() {
		if (isIdDefined()) {
			wire();
		}
	}

	public void wire() {
		getInstance();
	}

	public boolean isWired() {
		return true;
	}

	public ChannelType getDefinedInstance() {
		return isIdDefined() ? getInstance() : null;
	}

}
